
#include "jncPrimitives.h"
#include "jncTypeInfo.h"
#include "jncDefs.h"


#define PRIMTEMPLATE(jtype, ltype, itype, typconv)			\
  class CLASSNAME(jtype): public JncInterface {				\
    JNCINTERFACEIMPL(CLASSNAME(jtype), ltype)				\
      public:								\
    gReturnCode BOOST_PP_CAT(set_, jtype)(jncTypev b)			\
    {									\
      try {								\
	return gReturnCode(new ltype(typconv(jcmp<char*>(b))));		\
      }									\
      catch(boost::bad_any_cast& e)					\
	{								\
	  std::string msg("Conversion from ");				\
	  msg += std::string(std::string(getTypeName(b)) + " to ") + runtimeSymbol(); \
	  throw RnException(ECONV, msg.c_str(), e);			\
	}								\
    }									\
  };

PRIMITIVES // Basic Types Declarations

void getPrimitivesNamespace() {
  INIT_PRIMITIV_ARRAY,
    exportObjectHandle<CToken>(new CLASSNAME(Token)(), 
			       (const char* [JINC_MAX_ARG]){"token", "p_void", NULL}, 
			       (jncTypei [JINC_MAX_ARG]){JCMP, JCMP}, 
			       &CToken::BOOST_PP_CAT(set_, Token), 
			       NORMAL);
}


